import java.util.Arrays;
import java.util.StringTokenizer;


/**
 * @author Steve Duncan 
 * @author Matt Sponnar
 * 
 * Mutant class
 */
public class Mutant {
	private String name;
	private double data[] = new double[60];
	private int mutations[] = new int[6];
	private boolean prediction;
	private int maxLocation;

	Mutant(){
		name = "";
		for(int i = 0; i < data.length; i++)
			data[i] = 0;
		for(int j = 0; j < mutations.length; j++)
			mutations[j] = 0;
		this.setMutations();
		prediction = false;
		maxLocation = -1;
	}
	
	Mutant(String name, double data[]){
		this.name = name;
		this.data = data;
		this.setMutations();
	}
	
	Mutant(String name, double data[], boolean prediction){
		this(name, data);
		this.prediction = prediction;
	}

	public int getMaxLocation(){
		return maxLocation;
	}
	
	public void setMaxLocation(int num){
		maxLocation = num;
	}
	
	@Override
	public String toString() {
		return "Mutant [name=" + name + ", data=" + Arrays.toString(data)
				+ ", mutations=" + Arrays.toString(mutations) + "]" + " Prediction: " + prediction 
				+ " max location: " + maxLocation;
	}

	public int[] getMutations() {
		return mutations;
	}

	public void setMutations(int[] mutations) {
		this.mutations = mutations;
	}
	
	public boolean isPrediction() {
		return prediction;
	}

	public void setPrediction(boolean prediction) {
		this.prediction = prediction;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
		this.setMutations();
	}

	public double[] getData() {
		return data;
	}

	public double getData(int loc){
		return data[loc];
	}
	
	public void setData(double[] data) {
		this.data = data;
	}
	public void setData(int loc, double num){
		data[loc] = num;
	}
	
	private void setMutations(){
		
		StringTokenizer token = new StringTokenizer(this.name, ", ");
		String temp;
		
		while(token.hasMoreTokens()){
			temp = token.nextToken();
			
			if(temp.equalsIgnoreCase("A388") || temp.equalsIgnoreCase("388A")){
				this.mutations[0] = 1;
			}
			else if(temp.equalsIgnoreCase("A389") || temp.equalsIgnoreCase("389A")){
				this.mutations[1] = 1;
			}
			else if(temp.equalsIgnoreCase("A391") || temp.equalsIgnoreCase("391A")){
				this.mutations[2] = 1;
			}
			else if(temp.equalsIgnoreCase("A392") || temp.equalsIgnoreCase("392A")){
				this.mutations[3] = 1;
			}
			else if(temp.equalsIgnoreCase("A394") || temp.equalsIgnoreCase("394A")){
				this.mutations[4] = 1;
			}
			else if(temp.equalsIgnoreCase("A395") || temp.equalsIgnoreCase("395A")){
				this.mutations[5] = 1;
			}
			// special case
			else if(temp.equalsIgnoreCase("Mel")){
				this.mutations[0] = -1;
			}
		}
	}
	
	
	//test main
	public static void main(String[] args){
		
		double d[] = {0.0, 1.0};
		Mutant x = new Mutant("391A, A392",d);
		Mutant y = new Mutant();
		Mutant z = new Mutant("Mel",d, true);
	}
}
